package view.client;

import javax.swing.JOptionPane;

public class CheckUpdate implements Runnable  {
    private static double version = 0.59;
    private Frame f;
    private final Thread thread;
    
    public CheckUpdate(Frame f){
        this.f = f;
        thread = new Thread(this);
        thread.start();
    }

    public static double getVersion() {
        return version;
    }

    public static void setVersion(double aVersion) {
        version = aVersion;
    }

    @Override
    public void run() {
        if (Double.parseDouble(Updater.getLatestVersion()) > getVersion()) {
            f.isNew = false;
            f.setUpdateEnabled(true);
            JOptionPane.showMessageDialog(null, "Novo update disponível. Versão online bloqueada.");
        }else{
            f.isNew = true;
            f.setUpdateEnabled(false);
        }
    }
    
}
